import type { ID } from "/@/api/models";
import type { AppTypeEnum } from "/@/api/aiot/application/models";
import { WorkOrderItem } from "../serviceWorkOrder/models";

export interface AlarmCount {
  currentAlarmCount: string | number;
  historyAlarmCount: string | number;
}

export interface TabItem {
  key: string | number;
  tabName: string;
  countKey?: string;
  numberStyle?: any;
}

export interface ReleaseAlarm {
  description: string;
}

export interface SearchAlarmListReq {
  ackedBy: string;
  ackedState: number;
  ackedTime: string;
  alarmActiveState: number;
  alarmCode: string;
  alarmContent: string;
  alarmEventClass: number;
  alarmEventId: string;
  alarmEventType: number | string;
  alarmMessage: string;
  alarmName: string;
  alarmReceiveTime: string;
  alarmSeverity: number;
  confirmedBy: string;
  confirmedState: number;
  confirmedTime: string;
  createdOn: string;
  deactivatedBy: string;
  deactivatedState: number;
  deactivatedTime: string;
  dismissedBy: string;
  dismissedRemark: string;
  dismissedState: number;
  dismissedTime: string;
  equipmentId: string;
  equipmentName: string;
  projectId: string;
  projectName: string;
  transferredBy: string;
  transferredTime: string;
  transferredToWorkOrderState: number;
  updatedOn: string;
}

export type PartialSearchAlarmReq = Partial<SearchAlarmListReq>;
export type PartialAlarmResponse = Partial<AlarmResponse>;
export interface AlarmResponse {
  alarmEvent: AlarmItem;
  confirmAble: number;
  confirmProcessorInfo?: ProcessorInfo | null;
  deactivateAble: number;
  deactivateProcessorInfo?: ProcessorInfo | null;
  dismissAble: number;
  showWorkOrderAble: number;
  transferAble: number;
  processorRecords: {
    processRemark: string;
    processTime: string;
    processTitle: string;
    processorRecordType: string;
  }[];
}
export interface ProcessorInfo {
  processRemark: string;
  processTime: string;
  processorName: string;
  userId: string;
}
export interface AlarmItem {
  alarmContent: string;
  alarmEventClass: number;
  alarmEventClassDesc: string;
  alarmEventId: string;
  alarmEventType: number;
  alarmEventTypeDesc: string;
  alarmName: string;
  alarmSeverity: number;
  alarmSeverityDesc: string;
  confirmedState: number;
  confirmedStateDesc: string;
  deactivatedState: number;
  deactivatedStateDesc: string;
  equipmentId: string;
  equipmentName: string;
  equipmentNo: string;
  location: string;
  projectId: string;
  projectName: string;
  updatedOn: string;
  createdOn: string;
  workOrderId: string;
}
export type PartialAlarmItem = Partial<AlarmItem>;

export enum AlarmLevel {
  SOSO = 1,
  SERIOUS = 2,
  URGENT = 3,
}

export const AlarmLevelDetail: { [key: string]: { color: string; iconColor: string; text: string } } = {
  [AlarmLevel.SOSO]: {
    color: "blue",
    iconColor: "#4b8bf4",
    text: "一般",
  },
  [AlarmLevel.SERIOUS]: {
    color: "orange",
    iconColor: "#f5b83c",
    text: "严重",
  },
  [AlarmLevel.URGENT]: {
    color: "error",
    iconColor: "#f56d6a",
    text: "紧急",
  },
};

export enum AlarmEvent {
  FAULT = 0,
  M_FAULT = 1,
  E_FAULT = 2,
  HIDDEN_DANGER = 3,
  OTHER = 4,
}

export const AlarmEventDetail: { [key: string]: { text: string } } = {
  [AlarmEvent.FAULT]: {
    text: "故障",
  },
  [AlarmEvent.M_FAULT]: {
    text: "机械故障",
  },
  [AlarmEvent.E_FAULT]: {
    text: "电气故障",
  },
  [AlarmEvent.HIDDEN_DANGER]: {
    text: "安全隐患",
  },
  [AlarmEvent.OTHER]: {
    text: "其它",
  },
};

export interface TransWorkOrderReq {
  alarmEventId: string;
  workOrdersSaveRequest: WorkOrderItem;
}
